using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class StudentImport_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        string conn = "Provider=Microsoft.Jet.OLEDB.4.0; DataSource=";
        conn += @"C:\Inetpub\wwwroot\PlacementManagerWeb\StudentImport\AllUGStudents.xls";
        conn += ";Extended Properties=\"\"Excel 8.0;HDR=YES;\"\"";


        conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Inetpub\\wwwroot\\PlacementManagerWeb\\StudentImport\\AllUGStudents.xls;Extended Properties=\"Excel 12.0;HDR=YES\";";


        Response.Write(conn);

        OleDbConnection oledbConn = new OleDbConnection(conn);
        OleDbCommand cmd1 = new OleDbCommand("SELECT DISTINCT [Student Id], Surname FROM [Sheet1$]", oledbConn);
        OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
        objAdapter1.SelectCommand = cmd1;
        DataSet objDataset1 = new DataSet();
        objAdapter1.Fill(objDataset1, "XLData");
        GridView1.DataSource = objDataset1.Tables[0].DefaultView;
        GridView1.DataBind();

    }
}
